﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="AlwaysVisibleControl.aspx.cs" Inherits="Samples.Views.Samples.AlwaysVisibleControl" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
   
   <div class="demoarea">
        <div class="demoheading">AlwaysVisibleControl</div>
        <div id="alwaysVisibleDiv" style="width:230px;height:100px">
            <div style="color:DarkBlue;background-color:White;border-color:DarkBlue;border-width:2px;border-style:Solid;width:250px;z-index: 1;">
                <div style="width: 100%; height: 100%; vertical-align: middle; text-align: center;">
                    <p>Current Time:</p>
                    <span id="currentTime" style="font-size:xx-large;font-weight:bold;line-height:40px;">5:09:21 PM</span>
                </div>                    
	        </div>
	    </div>
    	
	    <fieldset>
	        <legend>Options</legend>
	        Horizontal Alignment:<br />
	        <%= Html.RadioButton("hSide", "Left", "0", true) %>
	        <%= Html.RadioButton("hSide", "Center", "1") %>
	        <%= Html.RadioButton("hSide", "Right", "2") %>
	        <br /><br />
	        Vertical Alignment:<br />
	        <%= Html.RadioButton("vSide", "Top", "0", true) %>
	        <%= Html.RadioButton("vSide", "Middle", "1") %>
	        <%= Html.RadioButton("vSide", "Bottom", "2") %>
	        <br /><br />
	        <input type="button" onclick="setOptions();" value="Set Options" />
	    </fieldset>
	</div>
	
    <% for (var i = 0; i < 500; i++) { %><br /><% } %>
    
    <%= Ajax.AlwaysVisibleControl("alwaysVisibleDiv") %>
    
    <script type="text/javascript" language="javascript">
    //<![CDATA[
        function updateTime() {
            var label = $get('currentTime');
            if (label) {
                var time = (new Date()).localeFormat('T');
                label.innerHTML = time;
            }
        }

        function setOptions() {
            var avc = $find('alwaysVisibleDiv_javascript_id');
            avc.set_HorizontalSide(getSelectedValue(document.getElementsByName('hSide')));
            avc.set_VerticalSide(getSelectedValue(document.getElementsByName('vSide')));
        }

        function getSelectedValue(elm) {
            var value = 0;
            for (var i = 0; i < elm.length; i++) {
                if (elm[i].checked) {
                    value = parseInt(elm[i].value);
                    break;
                }
            }

            return value;
        }
        
        (function() {
            updateTime();
            window.setInterval(updateTime, 1000);
        })();
    //]]>
    </script>
</asp:Content>
